using System;

namespace OpenSource.SpreadsheetFactory
{
    /// <summary>
    /// Selects a field or property to be included in the spreadsheet as a column
    /// </summary>
    [CLSCompliant(true)]
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
    public sealed class SpreadsheetColumnAttribute : Attribute
    {
        /// <summary>
        /// Gets or sets the title of the column.
        /// </summary>
        /// <value>The title of the column.</value>
        public string Title { get; private set; }

        /// <summary>
        /// Gets or sets the ordinal of the column
        /// </summary>
        /// <value>The ordinal of the column</value>
        public int Ordinal { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="SpreadsheetColumnAttribute"/> attribute.
        /// </summary>
        /// <param name="title">The title of the column</param>
        /// <remarks>
        /// Columns annotated with this constructor will be placed after columns with an ordinal specified.
        /// </remarks>
        public SpreadsheetColumnAttribute(string title)
            : this(title, Int32.MaxValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SpreadsheetColumnAttribute"/> attribute.
        /// </summary>
        /// <param name="title">The title of the column</param>
        /// <param name="ordinal">
        /// The ordinal of the column.
        /// The bigger this number is, the more to the the column is placed.</param>
        public SpreadsheetColumnAttribute(string title, int ordinal)
        {
            this.Title = title;
            this.Ordinal = ordinal;
        }
    }
}

